﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IBMS.Common;

namespace IBMS.Page
{
    public partial class Register : System.Web.UI.Page
    {
        private User newuser = new User();
        private DB db = new DB();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_zhuce_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                newuser.Password = newuser.MD5(this.password.Text.ToString());
                newuser.Name = this.username.Text.ToString();
                newuser.RealName = this.true_name.Text.ToString();
                newuser.UserType = this.DropDownList1.SelectedItem.Value.ToString();
                bool result=db.ExecuteNonQury("insert into Users(Name,RealName,Password,UserType) values('"+newuser.Name+"','"+newuser.RealName+"','"+newuser.Password+"','"+newuser.UserType+"')");
                if (result)
                {
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('添加成功'); window.close()", true);
                }
                else
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('操作失败'); window.location='UserRegister.aspx'", true);
            }
        }
    }
}